package hw3.proxy.core;

import org.apache.http.params.CoreConnectionPNames;
import org.apache.http.params.HttpParams;

/**
 * This class contains definitions of various configuration properties
 * 
 * @author Adam Levi
 * @author Marina Skarbovsky
 *
 */
public class ConfigurationProperties 
{
	//general constants
	public static final int KB = 1024;
	public static final int HTTP_SERVER_PORT = 80;
	
	//HTTP Connection
	public static final int SOCKET_TIMEOT = 5000;
	public static final int SOCKET_BUFFER_SIZE = 8 * KB;
	public static final boolean STALE_CONNECTION_CHK = false;
	public static final boolean TCP_NODELAY = true;
	
	//proxy
	public static final int MAX_RESPONSE_LEN_FOR_CACHING = 64 * KB;
	public static final String XHTML_MSG_PATH = "./data/xhtml/";
	
	public static void initializeHTTPConnectionParams(HttpParams params)
	{
		params.setIntParameter(
        		CoreConnectionPNames.SO_TIMEOUT, 
        		ConfigurationProperties.SOCKET_TIMEOT);
		params.setIntParameter(
        		CoreConnectionPNames.SOCKET_BUFFER_SIZE, 
        		ConfigurationProperties.SOCKET_BUFFER_SIZE);
		params.setBooleanParameter(
        		CoreConnectionPNames.STALE_CONNECTION_CHECK, 
        		ConfigurationProperties.STALE_CONNECTION_CHK);
		params.setBooleanParameter(
        		CoreConnectionPNames.TCP_NODELAY, 
        		ConfigurationProperties.TCP_NODELAY);
	}
	
	// debug constants
	public static boolean REPLACE_TOKENS = true;
	public static boolean ONLY_ALLOW_TEXTUAL_RESPONSES = true;
	
	// query related
	public static  boolean OUTPUT_TO_CONSOLE = true;
	public static boolean OUTPUT_TO_FRAME = false;
	public static boolean OUTPUT_TO_XHTML_FILE = false;
	public static String  XHTML_OUTPUT_FILENAME = "query_res_out.xhtml";
	public static boolean AUTO_OPEN_BROWSER = false;
}
